<template>
  <div>
    <el-table
      :data="tableData"
      style="width: 100%"
      border
      fit
      stripe
      highlight-current-row
      element-loading-text="数据加载中"
      show-summary :summary-method="getSummaries"
    >
<!--      <el-table-column prop="date" label="序号" width="70" align="center" fixed>-->
<!--        <template slot-scope="scope">-->
<!--          {{ (page - 1) * limit + scope.$index + 1 }}-->
<!--        </template>-->
<!--      </el-table-column>-->
      <el-table-column prop="ledger_area" label="作业区"  align="center" />

      <el-table-column prop="craft01" label="热洗井数" sortable align="center" />

      <el-table-column prop="craft02" label="化防井数" sortable align="center" />

      <el-table-column prop="craft03" label="化防+热洗井数" sortable align="center" />
    </el-table>
  </div>

</template>

<script>
export default {
  data: function() {
    return {
      page: 1,
      limit: 10,
      total: 0,
      tableData: [
      ],
      type: 1,
      statisticsQuery: [
        {

        }
      ]
    }
  },
  created() {
    this.getListPage()
  },
  methods: {
    getListPage() {
      this.$http.post('/summaryStatistics/method', {
        type:this.type
      }).then(response=>{
        this.tableData=response.data.data
      }).catch(err=>{
        this.$message.error(err)
      })
    },
    resetData() {
    },
    getSummaries(param) {
      const { columns, data } = param
      const sums = []
      columns.forEach((column, index) => {
        if (index === 0) {
          sums[index] = '合计'
          return
        }
        const values = data.map(item => Number(item[column.property]))
          sums[index] = values.reduce((prev, curr) => {
            const value = Number(curr)
            if (!isNaN(value)) {
              return prev + curr
            } else {
              return prev
            }
          }, 0)
      })
      return sums
    }
  }
}
</script>

<style scoped>

</style>
